﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LaughingDog.GameObjects;
using Microsoft.Xna.Framework;

namespace LaughingDog.Components.Shapes
{
    public class RectangleShape : Shape
    {
        private Vector2 mTopLeft;
        private Vector2 mBottomRight;

        public Vector2 TopLeft { get { return mTopLeft; } set { mTopLeft = value; Create(); } }
        public Vector2 BottomRight { get { return mBottomRight; } set { mBottomRight = value; Create(); } }

        public RectangleShape(GameObject gameObject)
            : base(gameObject)
        {
        }

        private void Create()
        {
            ClearVectors();

            AddVector(mTopLeft);
            AddVector(new Vector2(mTopLeft.X, mBottomRight.Y));
            AddVector(mBottomRight);
            AddVector(new Vector2(mBottomRight.X, mTopLeft.Y));
            AddVector(mTopLeft);
        }

        public void CreateFromBounds()
        {
            mTopLeft = Vector2.Zero - Renderer.Origin;
            mBottomRight = mTopLeft + Transform.ScaledSize;

            Create();
        }
    }
}
